#ifndef NETWORKMANAGER_H
#define NETWORKMANAGER_H


#define SERVER_ADDRESS "127.0.0.1"
#define SERVER_PORT	1337

#include <Windows.h>
#include "Buffer.h"


class Packet;
class NetworkManager
{
public:
	NetworkManager(void);
	virtual ~NetworkManager(void);

	virtual void Init(void);
	virtual void Shutdown(void);

	Packet* ReadPacket(void);
	void SendPacket(Packet* packet, SOCKET socket);
	void CopyToBuffer(char* data, int len);


	//static NetworkManager** GetInstance(void);

	bool IsRunning(void) const;
	SOCKET GetSocket(void) const;
	size_t GetBufferSize(void) const;

protected:			// annoying as F to have those private
	bool		m_isRunning;
	WSADATA		m_wsaData;
	SOCKET		m_socket;
	Buffer		m_packetBuffer;

	struct RecvThreadArgs
	{
		SOCKET socket;
		NetworkManager* mgr;
	};
	static void SocketRecvThread(RecvThreadArgs* args);
};
#endif